<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <link rel="stylesheet" href="../../css/main.css">
    <link rel="stylesheet" href="../../css/searchCount.css">
    <link rel="stylesheet" href="../../layui/css/formSelects-v4.css">
    <title>产值计算表-查询</title>
</head>
<body>
<form class="top layui-form">
    <div class="top_left">
        <div class="sels layui-form">
            <span>日期：</span>
            <div class="layui-inline" style="margin-right: 10px;">
                <input type="text" name="stars"  placeholder="选择日期" class="layui-input" id="t1">
            </div>
            <span>~</span>
            <div class="layui-inline" style="margin-left: 10px;">
                <input type="text" name="ends" placeholder="选择日期" class="layui-input" id="t2">
            </div>
        </div>
        <div class="sels layui-form">
            <span class="span">项目选择：</span>
            <div class="layui-input-inline">
                <select id="prts" xm-select="prts" xm-select-show-count="1" name="prts" class="valid">

                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <button type="button" lay-submit="" lay-filter="seach" class="layui-btn">搜索</button>
        <button type="button" onclick="exports()" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe621;</i>导出</button>
    </div>
</form>
<div id="searchCount">
    <div class="tabs">
        <table width="100%" id="searchC" border="1px" cellpadding="0" bordercolor="#c2c2c2" style="border-collapse:collapse;">
            <tr style="font-weight: bold">
                <td rowspan="2">工料机分类</td>
                <td rowspan="2">编号</td>
                <td rowspan="2">名称</td>
                <td colspan="3">工料机表</td>
                <td colspan="3">合同计价<br>产值</td>
                <td colspan="3">合同计量<br>产值</td>
                <td colspan="3">安全文明措施费<br>产值</td>
            </tr>
            <tr>
                <td>数量</td>
                <td>采购价</td>
                <td>合计1</td>
                <td>合同单价</td>
                <td>合计2</td>
                <td>清单编号</td>
                <td>结算计量</td>
                <td>量差</td>
                <td>合计3</td>
                <td>基数</td>
                <td>费率</td>
                <td>合计</td>
            </tr>
            <tr>
                <td v-if="length1 == 1" rowspan="2">直接费-材料费</td>
                <td v-if="length1>1" v-bind:rowspan="length1">直接费-材料费</td>
            </tr>
            <tr v-if="length1 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item1, index) in arrList.zhi_cai">
                <td>{{item1.t_num}}</td>
                <td>{{item1.t_name}}</td>
                <td>{{item1.num}}</td>
                <td>{{item1.notax_money}}</td>
                <td>{{item1.total_money}}</td>
                <td>{{item1.he_price}}</td>
                <td>{{item1.he_total}}</td>
                <td>{{item1.qing_number}}</td>
                <td>{{item1.jie_num}}</td>
                <td>{{item1.jie_num-item1.num}}</td>
                <td>{{item1.he_jietotal}}</td>
                <td>{{item1.an_jishu}}</td>
                <td>{{item1.an_fee}}%</td>
                <td>{{item1.an_total}}</td>
            </tr>
            <tr>
                <td v-if="length2 == 1" rowspan="2">专项措施费-材料</td>
                <td v-if="length2>1" v-bind:rowspan="length2">专项措施费-材料</td>
            </tr>
            <tr v-if="length2 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item2, index) in arrList.zhuan_cai">
                <td>{{item2.t_num}}</td>
                <td>{{item2.t_name}}</td>
                <td>{{item2.num}}</td>
                <td>{{item2.notax_money}}</td>
                <td>{{item2.total_money}}</td>
                <td>{{item2.he_price}}</td>
                <td>{{item2.he_total}}</td>
                <td>{{item2.qing_number}}</td>
                <td>{{item2.jie_num}}</td>
                <td>{{item2.jie_num-item2.num}}</td>
                <td>{{item2.he_jietotal}}</td>
                <td>{{item2.an_jishu}}</td>
                <td>{{item2.an_fee}}%</td>
                <td>{{item2.an_total}}</td>
            </tr>
            <tr>
                <td colspan="3">合计</td>
                <td></td>
                <td></td>
                <td>{{arrList.cai_heji}}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td v-if="length3 == 1" rowspan="2">直接费-人工费</td>
                <td v-if="length3>1" v-bind:rowspan="length3">直接费-人工费</td>
            </tr>
            <tr v-if="length3 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item3, index) in arrList.zhi_ren">
                <td>{{item3.t_num}}</td>
                <td>{{item3.t_name}}</td>
                <td>{{item3.num}}</td>
                <td>{{item3.notax_money}}</td>
                <td>{{item3.total_money}}</td>
                <td>{{item3.he_price}}</td>
                <td>{{item3.he_total}}</td>
                <td>{{item3.qing_number}}</td>
                <td>{{item3.jie_num}}</td>
                <td>{{item3.he_jietotal}}</td>
                <td>{{item3.he_jietotal}}</td>
                <td>{{item3.an_jishu}}</td>
                <td>{{item3.an_fee}}%</td>
                <td>{{item3.an_total}}</td>
            </tr>
            <tr>
                <td v-if="length4 == 1" rowspan="2">专项措施费-人工费</td>
                <td v-if="length4>1" v-bind:rowspan="length4">专项措施费-人工费</td>
            </tr>
            <tr v-if="length4 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item4, index) in arrList.zhuan_ren">
                <td>{{item4.t_num}}</td>
                <td>{{item4.t_name}}</td>
                <td>{{item4.num}}</td>
                <td>{{item4.notax_money}}</td>
                <td>{{item4.total_money}}</td>
                <td>{{item4.he_price}}</td>
                <td>{{item4.he_total}}</td>
                <td>{{item4.qing_number}}</td>
                <td>{{item4.jie_num}}</td>
                <td>{{item4.he_jietotal}}</td>
                <td>{{item4.he_jietotal}}</td>
                <td>{{item4.an_jishu}}</td>
                <td>{{item4.an_fee}}%</td>
                <td>{{item4.an_total}}</td>
            </tr>
            <tr>
                <td colspan="3">合计</td>
                <td></td>
                <td></td>
                <td>{{arrList.ren_heji}}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td v-if="length5 == 1" rowspan="2">直接费-机械费</td>
                <td v-if="length5>1" v-bind:rowspan="length5">直接费-机械费</td>
            </tr>
            <tr v-if="length5 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item5, index) in arrList.zhi_jixie">
                <td>{{item5.t_num}}</td>
                <td>{{item5.t_name}}</td>
                <td>{{item5.num}}</td>
                <td>{{item5.notax_money}}</td>
                <td>{{item5.total_money}}</td>
                <td>{{item5.he_price}}</td>
                <td>{{item5.he_total}}</td>
                <td>{{item5.qing_number}}</td>
                <td>{{item5.jie_num}}</td>
                <td>{{item5.he_jietotal}}</td>
                <td>{{item5.he_jietotal}}</td>
                <td>{{item5.an_jishu}}</td>
                <td>{{item5.an_fee}}%</td>
                <td>{{item5.an_total}}</td>
            </tr>
            <tr>
                <td v-if="length6 == 1" rowspan="2">专项措施费-机械费</td>
                <td v-if="length6>1" v-bind:rowspan="length6">专项措施费-机械费</td>
            </tr>
            <tr v-if="length6 == 1">
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr v-for="(item6, index) in arrList.zhuan_jixie">
                <td>{{item6.t_num}}</td>
                <td>{{item6.t_name}}</td>
                <td>{{item6.num}}</td>
                <td>{{item6.notax_money}}</td>
                <td>{{item6.total_money}}</td>
                <td>{{item6.he_price}}</td>
                <td>{{item6.he_total}}</td>
                <td>{{item6.qing_number}}</td>
                <td>{{item6.jie_num}}</td>
                <td>{{item6.he_jietotal}}</td>
                <td>{{item6.he_jietotal}}</td>
                <td>{{item6.an_jishu}}</td>
                <td>{{item6.an_fee}}%</td>
                <td>{{item6.an_total}}</td>
            </tr>
            <tr>
                <td colspan="3">合计</td>
                <td></td>
                <td></td>
                <td>{{arrList.jixie_heji}}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                  <td colspan="3">工料机合计</td>
                  <td colspan="3">{{arrList.total_gong}}</td>
                  <td colspan="3">{{arrList.total_jijia}}</td>
                  <td colspan="3">{{arrList.total_jiliang}}</td>
                  <td colspan="3">{{arrList.total_anquan}}</td>
              </tr>
        </table>
    </div>
    <div id="demo8"></div>
</div>
</body>
<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../layui/layui.all.js"></script>
<script type="text/javascript" src="../../js/vue.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
<script type="text/javascript" src="../../js/excel.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script src="../../layui/formSelects-v4.js"></script>
<script>

    var vm = new Vue({
        el: '#searchCount',
        data: {
            token: '',
            project_id: '',
            page: 1,
            limit: 12,
            arr: [],//项目列表
            ids:'',
            arrList:[],//数据
            length1:'',
            length2:'',
            length3:'',
            length4:'',
            length5:'',
            length6:'',
            permissions:''

        },
        created: function () {
            this.arr = JSON.parse(sessionStorage.getItem('project'));
            this.project_id = sessionStorage.getItem('projectopt');
            this.initData();
        },
        mounted:function () {

        },
        methods: {
            initData:function () {
                var load = layer.load(2, {
                    shade: [0.6, '#fff'] //0.1透明度的白色背景
                })
                var obj = {
                    project_id: this.project_id
                }
                $.when(PUATTRBUTE.REQUESTFUN('api/Change/chanzhiindex', obj).done(function(res){
                    layer.close(load);
                    if(res.code == 1){
                        vm.arrList = res.data;
                        vm.length1 = vm.arrList.zhi_cai.length+1;
                        vm.length2 = vm.arrList.zhuan_cai.length+1
                        vm.length3 = vm.arrList.zhi_ren.length+1
                        vm.length4 = vm.arrList.zhuan_ren.length+1
                        vm.length5 = vm.arrList.zhi_jixie.length+1
                        vm.length6 = vm.arrList.zhuan_jixie.length+1
                    }else{
                        if(res.msg == "暂无权限"){
                            vm.permissions= 1 ;
                        }
                        layer.msg(res.msg, {time: 1000, icon:2});
                    }
                }))
            }
        }
    })
    layui.use(['form', 'laydate', 'jquery'], function () {
        var form = layui.form,
            laydate = layui.laydate,
            formSelects = layui.formSelects;
        laydate.render({
            elem: '#t1', //指定元素
        })
        laydate.render({
            elem: '#t2', //指定元素
        })

        var arrs = vm.arr;
        var content = '';
        for (var i in arrs) {// 遍历数据赋值给二级列表的内容
            content += '<option value="' + arrs[i].id + '">' + arrs[i].name + '</option>';
        }
        $('#prts').append(content);
        layui.formSelects.render();
        layui.formSelects.value('prts', [vm.arr[0].id]);
        form.on("submit(seach)",function(data){
            var load = layer.load(2, {
                shade: [0.6, '#fff'] //0.1透明度的白色背景
            })
            var obj = {
                star: data.field.stars,
                end: data.field.ends,
                project_id: data.field.prts
            }
            $.when(PUATTRBUTE.REQUESTFUN('api/Change/chanzhiindex', obj).done(function(res){
                layer.close(load);
                if(res.code == 1){
                    layer.msg(res.msg, {time: 1000, icon:1});
                    vm.arrList = res.data;
                    vm.length1 = vm.arrList.zhi_cai.length+1;
                    vm.length2 = vm.arrList.zhuan_cai.length+1
                    vm.length3 = vm.arrList.zhi_ren.length+1
                    vm.length4 = vm.arrList.zhuan_ren.length+1
                    vm.length5 = vm.arrList.zhi_jixie.length+1
                    vm.length6 = vm.arrList.zhuan_jixie.length+1
                }else{
                    layer.msg(res.msg, {time: 1000, icon:2});
                }
            }))
        })
    })
    //导出
    function exports() {
        if(vm.permissions == 1){
            layer.alert("抱歉，您没有此权限！");
        }else {
            var tableHtml = $('#searchC');
            $(tableHtml).css({
                'border':'1px solid #d5d5d2',
                'text-align':'center',
                'border-collapse':'collapse',
            });
            $(tableHtml).find('tr td').css({
                'text-align':'center',
                'border':'1px solid #d5d5d2',
                'line-height':'30px',
                'padding':'0px 10px',
                'min-width':'100px'
            });
            var html = "<html><head><meta charset='utf-8' /></head><body>" + tableHtml[0].outerHTML + "</body></html>";
// 实例化一个Blob对象，其构造函数的第一个参数是包含文件内容的数组，第二个参数是包含文件类型属性的对象
            var blob = new Blob([html], { type: "application/vnd.ms-excel" });
            var urlA = document.createElement('a');
// 利用URL.createObjectURL()方法为a元素生成blob URL
            $('.table-btn-group').append(urlA);
            urlA.href = URL.createObjectURL(blob);
// 设置文件名，目前只有Chrome和FireFox支持此属性
            urlA.download = "产值计算表-查询.xls";
            urlA.click();
        }
    }
</script>
</html>

